package com.leemon.mall.security.service.impl;

import cn.hutool.captcha.AbstractCaptcha;
import cn.hutool.captcha.CaptchaUtil;
import com.leemon.mall.common.util.RedisUtil;
import com.leemon.mall.security.constants.SecurityConstants;
import com.leemon.mall.security.service.SysLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author limenglong
 * @create 2019-08-30 17:40
 * @desc SysLoginService实现类
 **/
@Service
public class SysLoginServiceImpl implements SysLoginService {

    @Autowired
    private RedisUtil redisUtil;

    @Override
    public AbstractCaptcha generateCaptcha(String uuid) {
        AbstractCaptcha captcha = CaptchaUtil.createShearCaptcha(200, 50, 5, 2);
        String code = captcha.getCode();
        redisUtil.set(SecurityConstants.SPRING_SECURITY_RESTFUL_IMAGE_CODE + uuid, code, 300);
        return captcha;
    }

    @Override
    public void logout() {

    }
}
